#include<stdio.h>
#include<stdlib.h>
#define MAX 50
#define MAS 100
typedef enum { false, true } bool;
typedef int ElementType;
typedef int Position;
typedef struct S* PtrSNode;
struct S {
	ElementType* data;
	Position top;
	int maxsize;
};
typedef PtrSNode Stack;
Stack CreateStack(int MaxSize);
bool IsEmpty(Stack S);
bool IsFull(Stack S);
bool Push(Stack S, ElementType X);
bool Pop(Stack S);
void KeepOut(Stack S);
int main()
{
	int N, M;
	char str[MAS];
	Stack S;
	scanf("%d %d\n", &N, &M);
	S = CreateStack(M);
	for (int i = 0; i < N; i++)
	{
		int j;
		scanf("%s", str);
		KeepOut(S);
		for (j = 0; str[j] != '\0'; j++)
		{
			if ((str[j] == 'S') && (!Push(S, 1))) break;
			if ((str[j] == 'X') && (!Pop(S))) break;
		}
		if ((str[j] == '\0') && IsEmpty(S)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
Stack CreateStack(int MaxSize)
{
	Stack S = (Stack)malloc(sizeof(struct S));
	S->data = (ElementType*)malloc(MaxSize * sizeof(ElementType));
	S->top = -1;
	S->maxsize = MaxSize;
	return S;
}
bool IsFull(Stack S)
{
	return(S->top == (S->maxsize - 1));
}
bool Push(Stack S, ElementType X)
{
	if (IsFull(S)) {
		return false;
	}
	else {
		S->data[++(S->top)] = X;
		return true;
	}
}
bool IsEmpty(Stack S)
{
	return(S->top == -1);
}
bool Pop(Stack S)
{
	if (IsEmpty(S)) {
		return false;
	}
	else
		(S->top)--;
	return true;
}
void KeepOut(Stack S)
{
	while (!IsEmpty(S))
		Pop(S);
}